//!
//! Copyright (c) 2024-2999 北京心月狐科技有限公司 All rights reserved.
//!
//! https://www.mxxshop.com
//!
//! Licensed 并不是自由软件，未经许可不能去掉 MxxShop 相关版权
//!
//! 版权所有，侵权必究！
//!

use actix_http::StatusCode;
use actix_session::Session;

use actix_web::{get, HttpResponse};
use actix_web::http::header::ContentType;
use minijinja::context;
use crate::core::errors::error::Result;
use rust_i18n::t;
use crate::core::service::template_service::get_template;


rust_i18n::i18n!("locales");
#[get("/")]
pub async fn index(session: Session) -> Result<HttpResponse> {
    let locale = "en";
    let ctx = context!(
        title => "MxxShop",
        lang_login => &t!("user.login", locale = locale),
        lang_signup => &t!("user.register", locale = locale)
    );
    let out = get_template("default/index.html", ctx)?;
    Ok(HttpResponse::Ok().content_type(ContentType::html()).body(out))
}


